<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id='app' v-cloak>
    <h2>{{message}}</h2>
    <!-- 3.使用组件 -->
    <cpn></cpn>
  </div>

  <div id="app2">
    <cpn></cpn>
  </div>
  <script src='../js/vue.js'></script>
  <script>
    // 1.创建组件构造器
    const cpn = Vue.extend({
      template: `
        <div>
          <h1>我是组件</h1>
          <h2>我是组件的凝北</h2>
          </div>
      `
    });
    // 2.注册组件(全局组件)
    // Vue.component('cpn', cpn);

    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello Vue'
      },
      // 局部组件注册
      components: {
        cpn: cpn
      }
    })

    const app2 = new Vue({
      el: '#app2'
    })
  </script>
  <style>
    [v-cloak] {
      display: none;
    }
  </style>
</body>

</html>